package com.techysky.repository;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.springframework.data.jpa.repository.Query;

import com.techysky.entity.PublicModule;

public interface PublicModuleRepository extends CoreRepository<PublicModule, Serializable>,Serializable {

	/**
	 * 
	 * @param parentId
	 * @return
	 */
	List<PublicModule> findByParentId(String parentId);
	
	
	List<PublicModule> findByProjectIdAndParentIdIsNull(String projectId);
	/**
	 *通过sql查询PM列表
	 */
	@Query("select new map(t.id as id,t.title as title,t.projectId as projectId,t.parentId as parentId) from PublicModule t where t.parentId=?1 ")
	List<Map<String,Object>> findByParentIdJql(String parentId);
	/**
	 *通过sql查询PM列表 一级pm，parent是空
	 */
	@Query("select new map(t.id as id,t.title as title,t.projectId as projectId,t.parentId as parentId) from PublicModule t where t.parentId is null ")
	List<Map<String,Object>> findByParentIdJqlNull();
	
	/**
	 * 
	 * @return
	 */
	List<PublicModule> findByParentIdIsNull();
}
